package com.googlecode.servus.content;

import java.net.URL;

public class DownloadManager {

    protected ContentRepository<byte[]> downloadedRepository;

    protected TransferListener transferListener;

    public DownloadManager(ContentRepository<byte[]> downloadedRepository, TransferListener transferListener) {
        this.downloadedRepository = downloadedRepository;
        this.transferListener = transferListener;
    }

    public void download(String name, URL url) {
        byte[] data = new TransferHandler(url).transfer(transferListener);
        downloadedRepository.save(name, data);
    }

}
